table of contents
- NAME
- SYNOPSIS
- DESCRIPTION
- LIBRARY INITIALISATION AND CLEANUP
- LIBRARY FUNCTIONS
- QUERY CONSTRUCTOR
- QUERY DESTRUCTOR
- QUERY METHODS
- GRAPH PATTERN CLASS
- GRAPH PATTERN CONSTRUCTOR
- QUERY RESULTS CLASS
- QUERY RESULTS CONSTRUCTOR
- QUERY RESULTS DESTRUCTOR
- QUERY RESULTS METHODS
- QUERY VARIABLE BINDINGS RESULTS METHODS
- QUERY BOOLEAN RESULTS METHODS
- QUERY RDF GRAPH RESULTS METHODS
- QUERY RESULTS FORMATTER CLASS
- QUERY RESULTS FORMATTER CONSTRUCTOR
- QUERY RESULTS FORMATTER DESTRUCTOR
- QUERY RESULTS FORMATTER METHODS
- QUERY RESULTS FORMATTER STATIC METHODS
- LITERAL CLASS
- LITERAL CONSTRUCTORS
- LITERAL COPY CONSTRUCTOR
- LITERAL DESTRUCTOR
- LITERAL METHODS
- TRIPLE CLASS
- TRIPLE CONSTRUCTOR
- TRIPLE COPY CONSTRUCTOR
- TRIPLE DESTRUCTOR
- TRIPLE METHODS
- VARIABLE CLASS
- VARIABLE CONSTRUCTOR
- VARIABLE DESTRUCTOR
- VARIABLE METHODS
- PREFIX CLASS
- PREFIX CONSTRUCTOR
- PREFIX DESTRUCTOR
- EXPRESSION CLASS
- EXPRESSION CONSTRUCTORS
- EXPRESSION COPY CONSTRUCTOR
- EXPRESSION DESTRUCTOR
- EXPRESSION METHODS
- DATA GRAPH CLASS
- DATA GRAPH CONSTRUCTOR
- DATA GRAPH DESTRUCTOR
- API CHANGES
- CONFORMING TO
- SEE ALSO
- AUTHOR
librasqal(3) | Library Functions Manual | librasqal(3) |
NAME¶
librasqal - Rasqal RDF query library
SYNOPSIS¶
#include <rasqal.h>
rasqal_init();
rasqal_query_results *results;
raptor_uri *base_uri=raptor_new_uri("http://example.org/foo");
rasqal_query *rq=rasqal_new_query("rdql",NULL);
const char *query_string="select * from <http://example.org/data.rdf>";
rasqal_query_prepare(rq,query_string,base_uri);
results=rasqal_query_execute(rq);
while(!rasqal_query_results_finished(results)) {
for(i=0;i<rasqal_query_results_get_bindings_count(results);i++) {
const char *name=rasqal_query_results_get_binding_name(results,i);
rasqal_literal *value=rasqal_query_results_get_binding_value(results,i);
/* ... */
}
rasqal_query_results_next(results);
}
rasqal_free_query_results(results);
rasqal_free_query(rq);
raptor_free_uri(base_uri);
rasqal_finish();
cc `rasqal-config --cflags` file.c `rasqal-config --libs`
DESCRIPTION¶
The Rasqal library provides a high-level interface to RDF query parsing, query construction, query execution over an RDF graph and query results manipulation and formatting. The library provides APIs to each of the steps in the process and provides support for handling multiple query language syntaxes. At present Rasqal partially supports the W3C draft SPARQL query language and fully supports RDQL.
Rasqal uses the libraptor(3) library for providing URI handling, WWW content retrieval and other support functions.
LIBRARY INITIALISATION AND CLEANUP¶
- rasqal_init()
- rasqal_finish()
- Initialise and cleanup the library. These must be called before any Rasqal class is created or used.
LIBRARY FUNCTIONS¶
These functions provide general library features not associated to any particular class.
- int rasqal_languages_enumerate(const unsigned int counter, const char **name, const char **label, const unsigned char **uri_string)
- Return the name, label, uri_string (all optional) for a query language with a given integer counter, returning non-zero if no such query language at that offset exists. The counter should start from 0 and be incremented by 1 until the function returns non-zero.
- int rasqal_language_name_check(const char *name)
- Check name is a known query language name.
- int rasqal_query_set_feature(rasqal_query* query, rasqal_feature feature, int value)
- Set a query feature feature to a particular integer value.
Returns non 0 on failure or if the feature is unknown. The current defined
parser features are:
Feature Values
RASQAL_FEATURE_NO_NET Boolean (non 0 true)
If the no_net feature is true (default false) then network requests are denied.
- int rasqal_query_set_feature_string(rasqal_query* query, rasqal_feature feature, const unsigned char* value)
- Set a query feature feature to a particular string value. Returns non 0 on failure or if the feature is unknown. The current defined query features are given in rasqal_query_set_feature and at present only take integer values. If an integer value feature is set with this function, value is interpreted as an integer and then that value is used.
- int rasqal_query_get_feature(rasqal_query* query, rasqal_feature feature)
- Get a query feature integer value. The allowed feature values and types are given under rasqal_features_enumerate.
- const unsigned char* rasqal_query_get_feature_string(rasqal_query* query, rasqal_feature feature)
- Get a query feature string value. The allowed feature values and types are given under rasqal_features_enumerate.
- int rasqal_features_enumerate(const rasqal_feature feature, const char** name, raptor_uri** uri, const char** label)
- Return the name, URI, string label (all optional) for a query feature, returning non-zero if no such feature exists.
- unsigned int rasqal_get_feature_count(void)
- Get the count of rasqal features defined which can be found with rasqal_features_enumerate.
Rasqal features have URIs that are constructed from the URI http://feature.librdf.org/rasqal- and the name so for example feature noNet has URI http://feature.librdf.org/rasqal-noNet
- rasqal_feature rasqal_feature_from_uri(raptor_uri* uri)
- Turn a URI uri into a rasqal feature identifier, or <0 if the feature is unknown. The URIs are described below rasqal_query_set_feature.
- int rasqal_feature_value_type(const rasqal_feature feature)
- Get a rasqal feature value tyype - integer or string.
QUERY CONSTRUCTOR¶
- rasqal_query* rasqal_new_query(const char *name, const unsigned char *uri)
- Create a new rasqal query object for the query syntax with name name. Currently "rdql" for the RDF Data Query Language and "sparql" for the SPARQL query language are recognised. A language may alternatively be identified by a URI uri. If name and uri are both NULL the default query language is selected, currently "sparql".
QUERY DESTRUCTOR¶
- void rasqal_free_query(rasqal_query* query)
- Destroy a rasqal query object.
QUERY METHODS¶
- const char* rasqal_query_get_name(rasqal_query* query)
- Get the query language name.
- const char* rasqal_query_get_label(rasqal_query* query)
- Get the query language human readable label.
- void rasqal_query_set_fatal_error_handler(rasqal_query* query, void *user_data, raptor_message_handler handler)
- Set the fatal error handler callback.
- void rasqal_query_set_error_handler(rasqal_query* query, void *user_data, raptor_message_handler handler)
- Set the error handler callback.
- void rasqal_query_set_warning_handler(rasqal_query* query, void *user_data, raptor_message_handler handler)
- Set the warning handler callback.
- int rasqal_query_get_distinct(rasqal_query* query)
- Get the query distinct mode flag as described in rasqal_query_set_distinct()
- void rasqal_query_set_distinct(rasqal_query* query, int mode)
- Set the query distinct results mode: 0 (none), 1 (SPARQL DISTINCT) or 2 (SPARQL REDUCE).
- int rasqal_query_get_limit(rasqal_query* query)
- Get the query-specified limit on results returning >= 0 if a limit is given, otherwise not specified.
- void rasqal_query_set_limit(rasqal_query* query, int limit)
- Set the query results limit. No more than limit results will be returned.
- int rasqal_query_get_offset(rasqal_query* query)
- Get the query-specified offset on results returning >= 0 if a offset is given, otherwise not specified.
- void rasqal_query_set_offset(rasqal_query* query, int offset)
- Set the query results offset. The first offset results will be not be returned.
- void rasqal_query_add_variable(rasqal_query* query, rasqal_variable* var)
- Add a variable binding to the sequence of bindings in the query.
- raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal_query* query)
- Get the sequence of variables that are returning bindings in the query such as when explicitly chosen via SELECT in RDQL or SPARQL or all variables mentioned with SELECT *.
- raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_query* query)
- Get the sequence of all variables mentioned in the query.
- rasqal_variable* rasqal_query_get_variable(rasqal_query* query, int idx)
- Get one variable binding in the sequence of variable bindings in the query.
- raptor_sequence* rasqal_query_get_anonymous_variable_sequence(rasqal_query* query)
- Get the raptor_sequence of anonymous variables mentioned in the query.
- int rasqal_query_has_variable(rasqal_query* query, const unsigned char *name)
- Return non-0 if the named variable is in the variable bindings of the query.
- int rasqal_query_set_variable(rasqal_query* query, const unsigned char *name, rasqal_literal* value)
- Set the query variable name to a literal value (the variable must already be in the sequence of variable bindings).
- raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* query)
- Get the sequence of triples to match in the query.
- rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int idx)
- Get one triple in the sequences of triples to match in the query.
- void rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* prefix)
- Add one namespace prefix/URI to the sequence of prefixes in the query.
- raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* query)
- Get the sequence of prefixes in the query.
- rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int idx)
- Get one prefix in the sequence of prefixes in the query at index idx.
- raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_query* query)
- Get the sequence of graph patterns expressions in the query.
- rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_query* query, int idx)
- Get a graph pattern in the sequence of graph_pattern expressions in the query.
- void rasqal_query_print(rasqal_query* query, FILE* stream)
- Print a query in a debug format. This format may change in any release.
- int rasqal_query_prepare(rasqal_query* query, const unsigned char *query_string, raptor_uri *base_uri)
- Prepare a query string query_stringwith optional base URI uri_string for execution, parsing it and modifying the rasqal_query internals. Return non-0 on failure.
- rasqal_query_results* rasqal_query_execute(rasqal_query* query)
- Execute a query, returning a rasqal_query_results* object or NULL on failure.
- void rasqal_query_set_user_data(rasqal_query* query, void *user_data)
- Set some user data to be associated with the query.
- void* rasqal_query_get_user_data(rasqal_query* query)
- Get the user data associated with the query.
- int rasqal_query_add_data_graph(rasqal_query* query, raptor_uri* uri, raptor_uri* name_uri, int flags)
- Add a data graph to the query's data sources, constructing a new data graph object with URI uri, optional name URI name_uri and flags. See rasqal_new_data_graph for a description of the argumetns.
- raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_query* query)
- Get the sequence of data graphs in the query.
- rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* query, int idx)
- Get one prefix in the sequence of prefixes in the query at index idx.
- raptor_sequence* rasqal_query_get_order_conditions_sequence(rasqal_query* query)
- Get the sequence of all result ordering conditions in the query, each of which is a rasqal_expression.
- rasqal_expression* rasqal_query_get_order_condition(rasqal_query* query, int idx)
- Get one result ordering condition expression in the sequence.
- rasqal_query_verb rasqal_query_get_verb(rasqal_query* query)
- Get the main query verb.
- int rasqal_query_get_wildcard(rasqal_query* query)
- Get the query verb wildcard flag signifying * in RDQL and SPARQL after the query verb.
- rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqal_query* query)
- Get the top query graph pattern of query.
- void rasqal_query_set_default_generate_bnodeid_parameters(rasqal_query* rdf_query, char* prefix, int base)
- Control the default method for generation of IDs for blank nodes. The method uses a short string prefix and an integer base to generate the identifier which is not guaranteed to be a strict concatenation. If prefix is NULL, the default is used. If base is less than 1, it is initialised to 1.
- void rasqal_query_set_generate_bnodeid_handler(rasqal_query* query, void* user_data, rasqal_generate_bnodeid_handler handler)
- Allow full customisation of the generated IDs by setting a callback handler and associated user_data that is called whenever a blank node or bag identifier is required. The memory returned is deallocated inside rasqal. Some systems require this to be allocated inside the same library, in which case the rasqal_alloc_memory function may be useful.
- rasqal_query_verb_as_string(rasqal_query_verb verb)
- Get a string for the query verb.
- raptor_sequence* rasqal_query_get_construct_triples_sequence(rasqal_query* query)
- Get the sequence of triples for a construct.
- rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* query, int idx)
- Get a triple in the sequence of construct triples.
- int rasqal_query_get_explain(rasqal_query* query)
- Get whether explain was given in the query.
- raptor_sequence* rasqal_query_get_group_conditions_sequence(rasqal_query* query)
- Get the sequence of result group bys in the graph pattern.
- rasqal_expression* rasqal_query_get_group_condition(rasqal_query* query, int idx)
- Get one group by expression in the sequences of result group bys in the graph pattern at index idx.
- int rasqal_query_write(raptor_iostream* iostr, rasqal_query* query, raptor_uri* format_uri, raptor_uri* base_uri)
- Write a formatted query to a raptor iostream iostr in format described by URI format_uri using base URI base_uri for relative URIs (or NULL).
- int rasqal_query_iostream_write_escaped_counted_string(rasqal_query* query, raptor_iostream* iostr, const unsigned char* string, size_t len)
- Write a string to an iostream in an escaped form suitable for the query string. Uses rasqal_query_escape_counted_string to perform the escaping.
- unsigned char* rasqal_query_escape_counted_string(rasqal_query* query, const unsigned char *string, size_t len, size_t* output_len_p)
- Convert a string of length len into an escaped form suitable for the query string. If output_len is not NULL, it is a pointer to the location to store the output string lenght. The returned string must be freed by the caller with rasqal_free_memory.
GRAPH PATTERN CLASS¶
A class for graph patterns in a query - a set of triple patterns) with flags and possible sub-graph patterns
GRAPH PATTERN CONSTRUCTOR¶
There is no public constructor for this class, it is constructed when the query is prepared from a syntax. The query methods rasqal_query_get_graph_pattern_sequence and rasqal_query_get_graph_pattern provide access to the top-level graph patterns in a query.
- rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_pattern* graph_pattern, int idx)
- Get a rasqal_triple inside a graph pattern at index idx returning NULL when the index is out of range.
- void rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, rasqal_graph_pattern* sub_graph_pattern)
- Add a sub-graph pattern sub_graph_pattern to the sequence of sub-graph patterns inside the graph pattern.
- raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern* graph_pattern)
- Get the sequence of sub-graph patterns inside the graph pattern returning NULL if there are no sub-graph patterns.
- rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, int idx)
- Get a sub-graph pattern inside the graph pattern at index idx returning NULL when the index is out of range.
- rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator(rasqal_graph_pattern* graph_pattern)
- Get the graph pattern operator to determine how the graph pattern should be interpreted.
- int rasqal_graph_pattern_get_flags(rasqal_graph_pattern* graph_pattern)
- Deprecated. Use rasqal_graph_pattern_get_operator instead.
- int rasqal_graph_pattern_add_constraint(rasqal_graph_pattern* gp, rasqal_expression* expr)
- Add a constraint expression expr to the sequence of constraints in the graph pattern.
- raptor_sequence* rasqal_graph_pattern_get_constraint_sequence(rasqal_graph_pattern* gp)
- Get the sequence of constraints in the graph pattern.
- rasqal_expression* rasqal_graph_pattern_get_constraint(rasqal_graph_pattern* gp, int idx)
- Get one constraint expression in the sequences of constraint to match in the graph pattern at index idx.
- int rasqal_graph_pattern_get_index(rasqal_graph_pattern* graph_pattern)
- Get the graph pattern absolute index in the array of graph patterns. The index is assigned when rasqal_query_prepareP is run on the query containing the graph pattern.
- void rasqal_graph_pattern_print(rasqal_graph_pattern* graph_pattern, FILE* fh)
- Print a graph pattern in a debug format. This format may change in any release.
- const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op)
- Utility function to get a graph pattern operator as a string.
- int rasqal_graph_pattern_visit(rasqal_graph_pattern* graph_pattern, rasqal_graph_pattern_visit_fn fn, void *user_data)
- Visit a user function fn recursively over the graph pattern and it's sub-graph patterns. The order is the first graph pattern at hand and then the arguments, if any. function fn is called at each point with the arguments of user_data and the graph pattern.
QUERY RESULTS CLASS¶
A class for the results of a query. The results can be in different formats - variable bindings, RDF graphs as a sequence of triples or a boolean result. The format returned is determined by the query which is query-language specific.
QUERY RESULTS CONSTRUCTOR¶
There is no public constructor for this class, the rasqal_query_results* is returned from rasqal_query_execute.
QUERY RESULTS DESTRUCTOR¶
- rasqal_free_query_results(rasqal_query_results *query_results)
- Destroy a rasqal query results object.
QUERY RESULTS METHODS¶
- int rasqal_query_results_is_bindings(rasqal_query_results* query_results)
- int rasqal_query_results_is_boolean(rasqal_query_results* query_results)
- int rasqal_query_results_is_graph(rasqal_query_results* query_results)
- int rasqal_query_results_is_syntax(rasqal_query_results* query_results);
- Return non-0 if the rasqal_query_results is of the given format. Only one of these will be non-0 for any result.
- int rasqal_query_results_write(raptor_iostream *iostr, rasqal_query_results *results, raptor_uri *format_uri, raptor_uri *base_uri)
- Write the query results in a syntax to the iostr iostream, the format of the syntax is given by the format_uri URI, with an optional base URI base_uri that may be used. The values of format_uri supported are provided by at runtime by the function rasqal_query_results_formats_enumerate(). This uses the librdf_query_results_formatter class internally.
QUERY VARIABLE BINDINGS RESULTS METHODS¶
- int rasqal_query_results_get_count(rasqal_query_results *query_result)
- Get the current number of variable bindings results returned. (Variable bindings results only)
- int rasqal_query_results_next(rasqal_query_results *query_results)
- Move to the next variable bindings result, returning non-0 on failure or results are exhausted. (Variable bindings results only)
- int rasqal_query_results_finished(rasqal_query_results *query_results)
- Find out if the variable binding results are exhausted, return non-0 if results are finished or the query failed. (Variable bindings results only)
- int rasqal_query_results_get_bindings(rasqal_query_results *query_results, const unsigned char ***names, rasqal_literal ***values)
- Get all variable binding names and values for the current result. If names is not NULL, it is set to the address of a shared array of names of the bindings (an output parameter). If values is not NULL, it is set to the address of a shared array of rasqal_literal* binding values. Note that both the names or values are shared and must not be freed by the caller. Returns non-0 if the assignment failed. (Variable bindings results only)
- rasqal_literal* rasqal_query_results_get_binding_value(rasqal_query_results *query_results, int offset)
- Get one variable binding literal value for the current result. Returns the value of the variable indexed in the sequence of variable bindings at position offset. (Variable bindings results only)
- const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results *query_results, int offset)
- Get the name of the variable indexed in the sequence of variable bindings at position offset. (Variable bindings results only)
- rasqal_literal* rasqal_query_results_get_binding_value_by_name(rasqal_query_results *query_results, const unsigned char *name)
- Get the value of the variable in the sequence of variable bindings named name or NULL if not known or unbound. (Variable bindings results only)
- int rasqal_query_results_get_bindings_count(rasqal_query_results *query_results)
- Get the number of bound variables in the variable bindings result or <0 on failure. (Variable bindings results only)
QUERY BOOLEAN RESULTS METHODS¶
- int rasqal_query_results_get_boolean(rasqal_query_results *query_results)
- Return the value of a boolean query result. This is meaningless if the query result is not a boolean. (Boolean result format only).
QUERY RDF GRAPH RESULTS METHODS¶
- raptor_statement* rasqal_query_results_get_triple(rasqal_query_results *query_results)
- Return the current triple in the RDF graph results or NULL at end of results or on failure. The returned raptor_statement is a shared pointer. (Graph results format only).
- int rasqal_query_results_next_triple(rasqal_query_results *query_results)
- Move to the next triple in the RDF graph results, returning non-0 at end of results or on failure. (Graph results format only).
QUERY RESULTS FORMATTER CLASS¶
A class for formatting the results of a query into a syntax.
QUERY RESULTS FORMATTER CONSTRUCTOR¶
- rasqal_query_results_formatter* rasqal_new_query_results_formatter(const char *name, raptor_uri* uri)
- Create a new query results formatter for the name or uri. The rasqal_query_results_formats_enumerate() function returns the allowed names and/or uris. If name and uri are both NULL, the default query results format is used.
- rasqal_query_results_formatter* rasqal_new_query_results_formatter_by_mime_type(const char *mime_type)
- Create a new query results formatter for the output mime_type. The rasqal_query_results_formats_enumerate_full() function returns the allowed names, uris and mime types. rasqal_query_results_formatter_get_mime_type() can return the mime type of a constructed object.
QUERY RESULTS FORMATTER DESTRUCTOR¶
- void rasqal_free_query_results_formatter(rasqal_query_results_formatter* formatter)
- Destroy a rasqal query results formatter object.
QUERY RESULTS FORMATTER METHODS¶
- int rasqal_query_results_formatter_write(raptor_iostream* iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri* base_uri)
- Write the query results formatted in a syntax to the iostr iostream an optional base URI base_uri.
- const char* rasqal_query_results_formatter_get_mime_type(rasqal_query_results_formatter* formatter)
- Get the mime type of the selected formatter.
QUERY RESULTS FORMATTER STATIC METHODS¶
- int rasqal_query_results_formats_enumerate(const unsigned int counter, const char** name, const char** label, const unsigned char** uri_string)
- Get query results formats information by counter. When counter is 0, this returns the default query results format. The name, label and/or uri_string may be returned if they are not NULL.
- int rasqal_query_results_formats_enumerate_full(const unsigned int counter, const char **name, const char **label, const unsigned char **uri_string, const char **mime_type)
- Get query results formats information by counter.. When counter is 0, this returns the default query results format. The name, label, uri_string and/or mime_type may be returned if they are not NULL.
- int rasqal_query_results_formats_check(const char *name, raptor_uri* uri, const char *mime_type)
- Check if a query results formatter with the given name, uri or mime_type exists, as would be used by the constructors rasqal_new_query_results_formatter() or rasqal_new_query_results_formatter_by_mime_type() if called.
LITERAL CLASS¶
A class for the values returned as parts of triples and in variable bindings. The rasqal_literal structure is public and defined in rasqal.h however note that some fields are used for different literal types in different ways. The types of literals are defined in the rasqal_literal_type enum.
LITERAL CONSTRUCTORS¶
There a several constructors for rasqal_literal to build them from simple types and existing rasqal_literal objects. NOTE: Any objects or strings passed into these constructors becomed owned by the literal object except where noted.
- rasqal_literal* rasqal_new_decimal_literal(const unsigned char* decimal)
- Create a new decimal literal from string decimal.
- rasqal_literal* rasqal_new_double_literal(double d)
- Create a new double literal from a d.
- rasqal_literal* rasqal_new_integer_literal(rasqal_literal_type type, int integer)
- Create a new integer literal of an integral type, either type RASQAL_LITERAL_INTEGER or RASQAL_LITERAL_BOOLEAN.
- rasqal_literal* rasqal_new_floating_literal(double f)
- DEPRECATED. Use rasqal_new_double_literal. Create a new floating literal from a f.
- rasqal_literal* rasqal_new_uri_literal(raptor_uri* uri)
- Create a new URI literal from a raptor_uri uri.
- rasqal_literal* rasqal_new_pattern_literal(const unsigned char *pattern, const char *flags)
- Create a new regular expression literal from regex pattern and flags.
- rasqal_literal* rasqal_new_string_literal(const unsigned char *string, const char *language, raptor_uri *datatype, const unsigned char *datatype_qname)
- Create a new Rasqal string literal. The datatype and datatype_qname parameters are alternatives; the QName is a datatype that cannot be resolved till later since the prefixes have not yet been declared or checked at the time this constructor is called.
- If the string literal is datatyped and of certain types recognised (currently xsd:decimal, xsd:double) it may be internally converted to a different literal type.
- rasqal_literal* rasqal_new_simple_literal(rasqal_literal_type type, const unsigned char *string)
- Create a new Rasqal simple literal of type RASQAL_LITERAL_BLANK or RASQAL_LITERAL_BLANK_QNAME.
- rasqal_literal* rasqal_new_boolean_literal(int value)
- Create a new Raqal boolean literal, where value is non-0 for true, 0 for false.
- rasqal_literal* rasqal_new_variable_literal(rasqal_variable* variable)
- Create a new Rasqal variable literal using an existing variable object.
LITERAL COPY CONSTRUCTOR¶
- rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* literal)
- Copy an existing literal object.
LITERAL DESTRUCTOR¶
- void rasqal_free_literal(rasqal_uri* literal)
- Destroy a rasqal literal object.
LITERAL METHODS¶
- void rasqal_literal_print(rasqal_literal* literal, FILE* fh)
- Print a literal in a debug format. This format may change in any release.
- rasqal_variable* rasqal_literal_as_variable(rasqal_literal* literal)
- Return a rasqal literal as a variable, if it is one, otherwise return NULL.
- const unsigned char* rasqal_literal_as_string(rasqal_literal* literal)
- Return a rasqal literal as a string value. This always succeeds. Return a rasqal literal as a string value according to flags. The only defined string value at present is RASQAL_COMPARE_XQUERY to use XQuery conversion rules. If error is not NULL, it will be set to non-0 if there is an error.
- rasqal_literal* rasqal_literal_as_node(rasqal_literal* literal)
- Return a new rasqal literal into one suitable for a node in an RDF triple or binding - as a URI, literal string (or datatyped) or blank node. The returned literal is owned by the caller and must be freed by rasqal_free_literal.
- int rasqal_literal_compare(rasqal_literal* literal1, rasqal_literal* literal2, rasqal_compare_flags flags, int* error)
- Compare two literals with type promotion across their range. If the types are not the same, they are promoted. If one is a floating, the other is promoted to floating, otherwise for integers, otherwise as strings (all literals have a string value).
- flags affects string comparisons. If the RASQAL_COMPARE_NOCASE bit is set, a case independent comparison is made.
- The return value is comparable to strcmp(3), first before second returns <0. equal returns 0, and first after second returns >0. If there is no ordering, such as for URIs, the return value is 0 for equal, non-0 for different (using raptor_uri_equals).
- int rasqal_literal_equals(rasqal_literal* literal1, rasqal_literal* literal2)
- Compare two literals with no type promotion If literal2's value is
a boolean, it will match
the string "true" or "false" in literal1.
TRIPLE CLASS¶
A class for triples of three literals, used for matching triples in a query where the literals may be variables as well as in then interface between Rasqal and RDF systems using RDF triples, when the literals may not be literals. The structure of this class is public and defined in rasqal.h
TRIPLE CONSTRUCTOR¶
- rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal_literal* predicate, rasqal_literal* object)
- Create a new rasqal triple from three literals.
TRIPLE COPY CONSTRUCTOR¶
- rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* triple)
- Copy an existing rasqal triple object.
TRIPLE DESTRUCTOR¶
- void rasqal_free_triple(rasqal_triple* triple)
- Destroy a rasqal triple object.
TRIPLE METHODS¶
- void rasqal_triple_print(rasqal_triple* triple, FILE* fh)
- Print a triple in a debug format. This format may change in any release.
- void rasqal_triple_set_origin(rasqal_triple* triple, rasqal_literal *literal)
- Set the origin rasqal_literal of the triple, typically a URI literal.
- rasqal_literal* rasqal_triple_get_origin(rasqal_triple* triple)
- Get the origin rasqal_literal of the triple.
- void rasqal_triple_set_flags(rasqal_triple* triple, unsigned int flags)
- DEPRECATED in rasqal 0.9.9+. Do not use.
- unsigned int rasqal_triple_get_flags(rasqal_triple* triple)
- DEPRECATED in rasqal 0.9.9+. Do not use.
VARIABLE CLASS¶
A class for variable name and literal used to capture a variable with optional value binding such as returned as query results by various methods. The structure of this class is public and defined in rasqal.h
VARIABLE CONSTRUCTOR¶
- rasqal_variable* rasqal_new_variable(rasqal_query* query, const unsigned char *name, rasqal_literal* value)
- Create a new rasqal variable scoped to a Rasqal query, with required name and optional rasqal_literal value. This creates a variable of type RASQAL_VARIABLE_TYPE_NORMAL.
- rasqal_variable* rasqal_new_variable_typed(rasqal_query* rq, rasqal_variable_type type, const unsigned char *name, rasqal_literal* value)
- Create a new rasqal variable scoped to a Rasqal query, with required name, optional rasqal_literal value and type type either RASQAL_VARIABLE_TYPE_NORMAL or RASQAL_VARIABLE_TYPE_ANONYMOUS
VARIABLE DESTRUCTOR¶
- void rasqal_free_variable(rasqal_variable* variable)
- Destroy a rasqal variable object.
VARIABLE METHODS¶
- void rasqal_variable_print(rasqal_variable* variable, FILE* fh)
- Print a variable in a debug format. This format may change in any release.
- void rasqal_variable_set_value(rasqal_variable* variable, rasqal_literal* literal)
- Set the value of a rasqal variable to an rasqal_literal value, freeing any current value. The new literal may be NULL.
PREFIX CLASS¶
A class for namespace name/URI prefix association used to shorten URIs in some query languages using XML-style QNames. The structure of this class is public and defined in rasqal.h
PREFIX CONSTRUCTOR¶
- rasqal_prefix* rasqal_new_prefix(const unsigned char* prefix, raptor_uri* uri)
- Create a new namespace prefix with the given short prefix and URI uri.
PREFIX DESTRUCTOR¶
- void rasqal_free_prefix(rasqal_prefix* prefix)
- Destroy a rasqal prefix object.
- void rasqal_prefix_print(rasqal_prefix* prefix, FILE* fh)
- Print a prefix in a debug format. This format may change in any release.
EXPRESSION CLASS¶
A class for constraint expressions over literals and variables. The expression operators are defined in rasqal.h as enum rasqal_op and take one, two or more complex parameters.
EXPRESSION CONSTRUCTORS¶
- rasqal_expression* rasqal_new_0op_expression(rasqal_op op)
- Create a new expression with a 0-argument operator.
- rasqal_expression* rasqal_new_1op_expression(rasqal_op op, rasqal_expression* arg)
- Create a new expression with a 1-argument operator.
- rasqal_expression* rasqal_new_2op_expression(rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2)
- Create a new expression with a 2-argument operator.
- rasqal_expression* rasqal_new_2op_expression(rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3)
- Create a new expression with a 3-argument operator.
- rasqal_expression* rasqal_new_string_op_expression(rasqal_op op, rasqal_expression* arg1, rasqal_literal* literal)
- Create a new expression with a 2-argument operator, the second of which is a literal string.
- rasqal_expression* rasqal_new_literal_expression(rasqal_literal* literal)
- Create a new expression over an existing rasqal literal.
- rasqal_expression* rasqal_new_variable_expression(rasqal_variable* variable)
- Create a new expression over an existing rasqal variable.
- rasqal_expression* rasqal_new_function_expression(raptor_uri* name, raptor_sequence* args)
- Create a new expression for a function named name and with sequence of rasqal_literal* arguments args.
- rasqal_expression* rasqal_new_cast_expression(raptor_uri* name, rasqal_expression* value)
- Create a new expression for a casting of value to a datatype with URI name.
EXPRESSION COPY CONSTRUCTOR¶
- rasqal_expression* rasqal_new_expression_from_expression(rasqal_expression* expression)
- Copy an existing rasqal expression object.
EXPRESSION DESTRUCTOR¶
- void rasqal_free_expression(rasqal_expression* expression)
- Destroy a rasqal expression object.
EXPRESSION METHODS¶
- void rasqal_expression_print_op(rasqal_expression* expression, FILE* fh)
- Print an expression operator in a debug format. This format may change in any release.
- void rasqal_expression_print(rasqal_expression* expression, FILE* fh)
- Print an expression in a debug format. This format may change in any release.
- rasqal_literal* rasqal_expression_evaluate(rasqal_query* query, rasqal_expression* expression, rasqal_compare_flags flags)
- Evalute an expression, returning a rasqal boolean with the result or NULL on failure. If flags are RASQAL_COMPARE_XQUERY then XQuery comparison and type promotions are used.
- int rasqal_expression_visit(rasqal_expression* expression, rasqal_expression_visit_fn fn, void *user_data)
- Visit a user function fn recursively over the expression and it's sub-expressions. The order is the first expression at hand and then the arguments, if any. function fn is called at each point with the arguments of user_data and the expression.
- int rasqal_expression_foreach(rasqal_expression* expression, rasqal_expression_foreach_fn fn, void *user_data)
- DEPRECATED. Use rasqal_expression_visit instead.
- Apply the function fn recursively over the expression and it's sub-expressions. The order is the first expression at hand and then the arguments, if any. function fn is called at each point with the arguments of user_data and the expression.
DATA GRAPH CLASS¶
A class for graph data sources to query over from a source URI with an optional name URI.
DATA GRAPH CONSTRUCTOR¶
- rasqal_data_graph* rasqal_new_data_graph(raptor_uri* uri, raptor_uri* name_uri, int flags)
- Create a new data graph with source URI uri and optional name URI name_uri. Flags can be RASQAL_DATA_GRAPH_NONE, RASQAL_DATA_GRAPH_NAMED or RASQAL_DATA_GRAPH_BACKGROUND.
DATA GRAPH DESTRUCTOR¶
- void rasqal_free_data_graph(rasqal_data_graph* dg)
- Destroy a rasqal data_graph object.
- void rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh)
- Print a data graph in a debug format. This format may change in any release.
API CHANGES¶
0.9.14¶
Added rasqal_new_0op_expression.
Added rasqal_new_query_results_formatter_by_mime_type and rasqal_query_results_formatter_get_mime_type.
Added rasqal_query_results_formats_check and rasqal_query_results_formats_enumerate_full.
Added 0y_results_is_syntax.
Added query results group by accessor methods: rasqal_query_get_group_conditions_sequence and rasqal_query_get_group_condition for LAQRS.
rasqal_query_set_distinct now takes a mode argument.
Added new query verbs RASQAL_QUERY_VERB_DELETE and RASQAL_QUERY_VERB_INSERT for LAQRS.
Added rasqal_query_get_explain
rasqal_expression structure looses an unused field variable.
Added rasqal_expression types RASQAL_EXPR_GROUP_COND_ASC, RASQAL_EXPR_GROUP_COND_DESC, RASQAL_EXPR_COUNT and RASQAL_EXPR_VARSTAR for LAQRS.
rasqal_variable structure gains a new field expression for LAQRS..
Added static variables rasqal_license_string and rasqal_home_url_string
0.9.13¶
Added rasqal_feature system with single feature RASQAL_FEATURE_NO_NET and functions rasqal_feature_from_uri, rasqal_feature_value_type, rasqal_features_enumerate, rasqal_get_feature_count, rasqal_query_get_feature, rasqal_query_get_feature_string, rasqal_query_set_feature and rasqal_query_set_feature_string. int.
Added rasqal_query_results_formatter class with constructor rasqal_new_query_results_formatter destructor rasqal_free_query_results_formatter and method rasqal_query_results_formatter_write.
Added rasqal_query_results_formats_enumerate for listing supported formats.
0.9.12¶
Added rasqal_query_iostream_write_escaped_counted_string and rasqal_query_escape_counted_string
Added rasqal_query_get_anonymous_variable_sequence
Added rasqal_graph_pattern_get_index
Added RASQAL_EXPR_REGEX to rasqal_op
Added arg3 field to rasqal_expression for the REGEX operation.
Added rasqal_query_write
Added rasqal_new_3op_expression
Added rasqal_literal_as_string_flags
0.9.11¶
Added enum rasqal_compare_flags flags for rasqal_expression_evaluate or rasqal_literal_compare.
Function rasqal_expression_evaluate gains a flag argument.
Added rasqal_expression_visit and type for visitor function rasqal_expression_visit_fn.
Added rasqal_new_expression_from_expression.
Deprecated rasqal_expression_foreach, replaced by rasqal_expression_visit.
Remove unused rasqal_new_variable_expression prototype.
Added rasqal_graph_pattern_visit and type for visitor function rasqal_graph_pattern_visit_fn.
Added rasqal_new_decimal_literal.
Deprecated rasqal_new_floating_literal replaced by new rasqal_new_double_literal.
Added rasqal_op type RASQAL_EXPR_LANGMATCHES for SPARQL langMatches().
Added rasqal_literal types: RASQAL_LITERAL_DECIMAL, RASQAL_LITERAL_DATETIME, RASQAL_LITERAL_DOUBLE (replacing deprecated RASQAL_LITERAL_FLOATING) and RASQAL_LITERAL_FLOAT.
Reordered the rasqal_literal types in the enum.
0.9.10¶
Added an rasqal_graph_pattern_operator enumerated type. with the following (useful) values: RASQAL_GRAPH_PATTERN_OPERATOR_BASIC (for triple patterns), RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL (for SPARQL OPTIONAL), RASQAL_GRAPH_PATTERN_OPERATOR_UNION, RASQAL_GRAPH_PATTERN_OPERATOR_GROUP and RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH (for SPARQL GRAPH).
Added graph pattern method rasqal_graph_pattern_get_operator Deprecated rasqal_graph_pattern_get_flags replaced by the above. Added helper function rasqal_graph_pattern_operator_as_string.
Modified the type of the final argument of rasqal_new_graph_pattern_from_sequence and rasqal_graph_pattern_add_triples from an integer to a rasqal_graph_pattern_operator enumeration.
Removed documentation of removed functions deprecated in 0.9.9.
0.9.9¶
Added query methods rasqal_query_get_construct_triple, rasqal_query_get_construct_triples_sequence, rasqal_query_get_offset, rasqal_query_get_order_condition, rasqal_query_get_order_conditions_sequence, rasqal_query_get_query_graph_pattern, rasqal_query_get_verb, rasqal_query_get_wildcard. rasqal_query_set_default_generate_bnodeid_parameters, rasqal_query_set_distinct, rasqal_query_set_generate_bnodeid_handler, rasqal_query_set_limit and rasqal_query_set_offset.
Added expressions RASQAL_EXPR_ORDER_COND_ASC, RASQAL_EXPR_ORDER_COND_DESC and RASQAL_EXPR_ORDER_COND_NONE.
Added enum rasqal_variable_type for typing variables.
Added variable constructor rasqal_new_variable_typed to create typed variables.
Added enum rasqal_query_verb for the main query verbs with values RASQAL_QUERY_VERB_SELECT, RASQAL_QUERY_VERB_CONSTRUCT RASQAL_QUERY_VERB_DESCRIBE and RASQAL_QUERY_VERB_ASK.
Added rasqal_query_verb_as_string to get a strign for a query verb.
Deprecated the rasqal_triple flags field and the triple methods rasqal_triple_set_flags and rasqal_triple_get_flags.
0.9.8¶
Added a Data Graph class with constructor rasqal_new_data_graph, destructor rasqal_free_data_graph and debug method rasqal_data_graph_print.
Added casting expressions with type RASQAL_EXPR_CAST and expression constructor rasqal_new_cast_expression
Added a no-arg graph pattern constructor rasqal_new_graph_pattern
Added graph pattern methods rasqal_graph_pattern_add_triples to add triples to a graph pattern and rasqal_graph_pattern_add_sub_graph_pattern to add a sub-graph pattern to a graph pattern.
Added graph pattern methods rasqal_graph_pattern_add_constraint, rasqal_graph_pattern_get_constraint_sequence and rasqal_graph_pattern_get_constraint to add constraints to a graph pattern.
Added query methods for data graphs: rasqal_query_add_data_graph, rasqal_query_get_data_graph_sequence, rasqal_query_get_data_graph.
Deprecated query methods: rasqal_query_add_constraint, rasqal_query_get_constraint_sequence rasqal_query_get_constraint, rasqal_query_add_source, rasqal_query_get_source_sequence and rasqal_query_get_source.
Removed deprecated query methods: rasqal_query_get_variable_sequence and rasqal_query_add_triple.
0.9.7¶
Export rasqal_graph_pattern typedef for graph patterns and
added access methods: rasqal_query_get_graph_pattern_sequence
rasqal_query_get_graph_pattern,
rasqal_graph_pattern_get_triple,
rasqal_graph_pattern_get_sub_graph_pattern_sequence,
rasqal_graph_pattern_get_sub_graph_pattern,
rasqal_graph_pattern_get_flags
and exported previously internal
rasqal_graph_pattern_print Export
rasqal_pattern_flags enum for graph pattern flags.
Added rasqal_query_get_bound_variable_sequence and rasqal_query_get_all_variable_sequence.
Deprecate rasqal_query_get_variable_sequence prefering rasqal_query_get_bound_variable_sequence
Added rasqal_query_get_distinct and rasqal_query_get_limit to get access to query flags.
Deleted RASQAL_EXPR_PATTERN which was never used.
0.9.6¶
Added new 1-argument expressions to the expression constructor; rasqal_op enum gained the following values: RASQAL_EXPR_LANG, RASQAL_EXPR_DATATYPE, RASQAL_EXPR_BOUND, RASQAL_EXPR_ISURI, RASQAL_EXPR_ISBLANK and RASQAL_EXPR_ISLITERAL
Added user-defined function expressions to the expression constructor: rasqal_op enum gained RASQAL_EXPR_FUNCTION value; rasqal_expression gained name and args fields and added rasqal_new_function_expression to construct a function expression.
Added rasqal_query_results_is_bindings, rasqal_query_results_is_boolean and rasqal_query_results_is_graph to test the format of query result.
Added rasqal_query_results_get_boolean to get the value of a boolean query result.
Added rasqal_query_results_get_triple and rasqal_query_results_next_triple to return an RDF graph query result.
Added rasqal_new_triple_from_triple triple copy constructor.
0.9.5¶
Added rasqal_query_results_write to format query results into a syntax, written to a raptor iostream.
Changed rasqal_new_floating_literal to take a double argument.
Added flags for triples with rasqal_triple_get_flags and rasqal_triple_set_flags to get and set them.
Added rasqal_triple_parts enum and updated the bind_match factory method of the rasqal_triples_match structure to take and return them.
Added a rasqal_triple_parts type field parts to the rasqal_triple_meta structure
0.9.4¶
No API changes.
0.9.3¶
The struct rasqal_prefix gained a declared field.
The struct rasqal_triple gained an origin field; not used at present but intended to support work on tracking triple provenance such as provided by Redland Contexts.
Added methods rasqal_triple_set_origin and rasqal_triple_get_origin to support the above.
struct rasqal_triple_meta now takes a 4-array of bindings, the fourth being the origin.
Exported function rasqal_set_triples_source_factory publically as intended.
0.9.2¶
Several functions changed their parameters or return values from char* to unsigned char* or const unsigned char* to reflect the actual use.
Changed to return a const unsigned char*:
rasqal_literal_as_string
Changed to take const unsigned char* (or add const):
rasqal_new_floating_literal
rasqal_new_pattern_literal
rasqal_new_prefix
rasqal_new_simple_literal
rasqal_new_string_literal
rasqal_new_variable
rasqal_query_has_variable
rasqal_query_results_get_binding_name
rasqal_query_results_get_binding_value_by_name
rasqal_query_results_get_bindings
rasqal_query_set_variable
0.9.1¶
Added the rasqal_query_results class and moved the results methods from rasqal_query.
Made rasqal_query_execute return a rasqal_query_result*.
Renamed all rasqal_query*result* methods to be rasqal_query_result_* Added rasqal_free_query_results to tidy up.
OLD API (0.9.0) NEW API (0.9.1+)
rasqal_query_get_result_count rasqal_query_results_get_count
rasqal_query_next_result rasqal_query_results_next
rasqal_query_results_finished rasqal_query_results_finished
rasqal_query_get_result_bindings rasqal_query_results_get_bindings
rasqal_query_get_result_binding_value rasqal_query_results_get_binding_value
rasqal_query_get_result_binding_name rasqal_query_results_get_binding_name
rasqal_query_get_result_binding_by_name rasqal_query_results_get_binding_value_by_name
rasqal_query_get_bindings_count rasqal_query_results_get_bindings_count
0.9.0¶
All new.
CONFORMING TO¶
SPARQL Query Language for RDF, Eric Prud'hommeaux and Andy Seaborne (eds), W3C Candidate Recommendation, 6 April 2006. http://www.w3.org/TR/2006/CR-rdf-sparql-query-20060406/
SPARQL Query Results XML Format, Jeen Broekstra and Dave Beckett (eds), W3C Candidate Recommendation, 6 April 2006. http://www.w3.org/TR/2006/CR-rdf-sparql-XMLres-20060406/
RDQL - A Query Language for RDF, Andy Seaborne, W3C Member Submission 9 January 2004 http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/
SEE ALSO¶
AUTHOR¶
Dave Beckett - http://purl.org/net/dajobe/
2007-04-22 |